﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CEOList.aspx.cs" MasterPageFile="~/MasterPages/Core.Master"
    Inherits="Pap.Web.Modules.Loan.Views.CEOList" meta:resourcekey="PageResource1" %>

<asp:Content runat="server" ContentPlaceHolderID="ContentPlaceHolder1">

    <script type="text/javascript">
        var BoardDecisionRenderer = function(value) {
            var r = storeDecisions.getById(value);
            if (Ext.isEmpty(r)) {
                return "";
            }
            return r.data.DecisionName;
        }
    </script>

    <ext:Store runat="server" ID="storeBoards" AutoLoad="True" IDMode="Legacy" meta:resourcekey="storeBoardsResource1"
        SerializationMode="Simple">
        <Reader>
            <ext:JsonReader ReaderID="BoardID">
                <Fields>
                    <ext:RecordField Name="BoardID" />
                    <ext:RecordField Name="CommitteeName" />
                    <ext:RecordField Name="ExpertName" />
                    <ext:RecordField Name="BoardNumber" />
                    <ext:RecordField Name="BoardDate" Type="Date" />
                    <ext:RecordField Name="BoardStatus" />
                    <ext:RecordField Name="DecisionID" />
                    <ext:RecordField Name="Notes" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:Store ID="storeDecisions" runat="server" IDMode="Static">
        <Reader>
            <ext:JsonReader ReaderID="DecisionID">
                <Fields>
                    <ext:RecordField Name="DecisionID" />
                    <ext:RecordField Name="DecisionName" />
                </Fields>
            </ext:JsonReader>
        </Reader>
        <SortInfo Direction="ASC"></SortInfo>
    </ext:Store>
    <ext:Store runat="server" ID="storeBoardLoans" AutoLoad="True" meta:resourcekey="storeBoardLoansResource1"
        SerializationMode="Simple">
        <Reader>
            <ext:JsonReader ReaderID="LoanID">
                <Fields>
                    <ext:RecordField Name="LoanID" />
                    <ext:RecordField Name="LoanNumber" />
                    <ext:RecordField Name="LoanCreatedDate" Type="Date" />
                    <ext:RecordField Name="CustomerName" />
                    <ext:RecordField Name="LoanType" />
                    <ext:RecordField Name="BoardLoanAmount" />
                    <ext:RecordField Name="BoardPaymentPeriod" />
                    <ext:RecordField Name="BoardDecision" />
                    <ext:RecordField Name="PreviousNotes" />
                    <ext:RecordField Name="ReviewerDecision" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:FitLayout runat="server">
        <ext:FormPanel runat="server" AutoScroll="true" meta:resourcekey="fpanlBoardMomResource1">
            <Body>
                <ext:FormLayout ID="FormLayout1" runat="server" meta:resourcekey="FormLayout1Resource1">
                    <ext:Anchor>
                        <ext:GridPanel runat="server" ID="grvBoards" StoreID="storeBoards" Title="<%$ Resources:grvBoardsTitle %>"
                            TrackMouseOver="True" AutoHeight="true" AutoScroll="true" AutoWidth="True" meta:resourcekey="grvBoardsResource1"
                            SelectionSavingBuffer="10">
                            <ColumnModel>
                                <Columns>
                                    <ext:Column DataIndex="BoardNumber" Header="<%$ Resources:grvHeaderBoardNumber %>"
                                        Sortable="True">
                                    </ext:Column>
                                    
                                    <ext:Column DataIndex="CommitteeName" Header="<%$ Resources:grvHeaderCommittee %>"
                                        Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="ExpertName" Header="<%$ Resources:grvHeaderExpert %>" Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="BoardDate" Header="<%$ Resources:grvHeaderBoardDate %>" Sortable="True">
                                        <Renderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
                                    </ext:Column>
                                    <ext:Column DataIndex="BoardStatus" Header="<%$ Resources:grvHeaderBoardStatus %>"
                                        Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="Notes" Header="<%$ Resources:grvHeaderBoardNotes %>">
                                        <Editor>
                                            <ext:TextArea ID="txtNotes" runat="server" />
                                        </Editor>
                                    </ext:Column>
                                    <ext:Column DataIndex="DecisionID" Header="<%$ Resources:grvHeaderBoardDecision %>"
                                        Sortable="True">
                                        <Renderer Fn="BoardDecisionRenderer" />
                                        <Editor>
                                            <ext:ComboBox runat="server" ID="cmbBoardDecision" StoreID="storeDecisions" DisplayField="DecisionName"
                                                ValueField="DecisionID" Editable="false" TypeAhead="True" TriggerAction="All"
                                                Visible="False" meta:resourcekey="cmbLoanDecisionResource1">
                                            </ext:ComboBox>
                                        </Editor>
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                            <SelectionModel>
                                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SelectedIndex="-1">
                                    <AjaxEvents>
                                        <SelectionChange OnEvent="Board_Selected" Before="#{grvBoardLoan}.body.mask('...', 'x-mask-loading');"
                                            Success="#{grvBoardLoan}.body.unmask();" />
                                    </AjaxEvents>
                                </ext:RowSelectionModel>
                            </SelectionModel>
                        </ext:GridPanel>
                    </ext:Anchor>
                    <ext:Anchor>
                        <ext:GridPanel runat="server" ID="grvBoardLoan" StoreID="storeBoardLoans" Title="<%$ Resources:grvBoardLoansTitle %>"
                            TrackMouseOver="True" AutoScroll="True" AutoHeight="true" meta:resourcekey="grvBoardLoanResource1">
                            <ColumnModel>
                                <Columns>
                                    <ext:Column DataIndex="LoanNumber" Header="<%$ Resources:grvHeaderLoanNumber %>"
                                        Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="LoanCreatedDate" Header="<%$ Resources:grvHeaderLoanCreatedDate %>"
                                        Sortable="True">
                                        <Renderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
                                    </ext:Column>
                                    <ext:Column DataIndex="LoanType" Header="<%$ Resources:grvHeaderLoanType %>" Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="BoardLoanAmount" Header="<%$ Resources:grvHeaderBoardLoanAmount %>"
                                        Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="BoardPaymentPeriod" Header="<%$ Resources:grvHeaderBoardPaymentPeriod %>"
                                        Sortable="True">
                                    </ext:Column>
                                    <ext:Column DataIndex="ReviewerDecision" Header="<%$Resources:grvHeaderReviewerDecision %>" />
                                    <ext:Column DataIndex="BoardDecision" Header="<%$Resources:grvLoansHeaderBoardDecision %>" />
                                    <ext:Column DataIndex="PreviousNotes" Header="<%$ Resources:PreviousNotes %>" Sortable="True">
                                    </ext:Column>
                                </Columns>
                            </ColumnModel>
                        </ext:GridPanel>
                    </ext:Anchor>
                </ext:FormLayout>
            </Body>
            <BottomBar>
                <ext:StatusBar ID="StatusBar1" runat="server" meta:resourcekey="StatusBar1Resource1">
                    <Items>
                        <ext:Button runat="server" ID="btnCancle" Icon="ArrowUndo" meta:resourcekey="btnCancleResource1">
                            <AjaxEvents>
                                <Click OnEvent="BtnCancle_Clicked" />
                            </AjaxEvents>
                        </ext:Button>
                        <ext:Button runat="server" ID="btnSubmit" Icon="Accept" meta:resourcekey="btnSubmitResource1">
                            <AjaxEvents>
                                <Click OnEvent="BtnSubmit_Clicked">
                                    <ExtraParams>
                                        <ext:Parameter Name="grvBoardsGrid" Mode="Raw" Value="Ext.encode(#{grvBoards}.getRowsValues(false))" />
                                    </ExtraParams>
                                </Click>
                            </AjaxEvents>
                        </ext:Button>
                    </Items>
                </ext:StatusBar>
            </BottomBar>
        </ext:FormPanel>
    </ext:FitLayout>
</asp:Content>
